package com.qinggeng.project.system.service.impl;

import com.qinggeng.common.utils.DateUtils;
import com.qinggeng.project.system.domain.UserAddress;
import com.qinggeng.project.system.mapper.UserAddressMapper;
import com.qinggeng.project.system.service.IUserAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户收货地址信息Service业务层处理
 *
 * @author qinggeng
 * @date 2020-05-28
 */
@Service
public class UserAddressServiceImpl implements IUserAddressService
{
    @Resource
    private UserAddressMapper userAddressMapper;

    /**
     * 查询用户收货地址信息
     *
     * @param addressId 用户收货地址信息ID
     * @return 用户收货地址信息
     */
    @Override
    public UserAddress selectUserAddressById(Long addressId)
    {
        return userAddressMapper.selectUserAddressById(addressId);
    }

    @Override
    public UserAddress selectUserAddressByUserId(Long userId, Long shopId) {
        return userAddressMapper.selectUserAddressByUserId(userId,shopId);
    }

    @Override
    public UserAddress selectUserAddressByLocation(Long userId, Float lng, Float lat) {
        return userAddressMapper.selectUserAddressByLocation(userId,lng,lat);
    }

    /**
     * 查询用户收货地址信息列表
     *
     * @param userAddress 用户收货地址信息
     * @return 用户收货地址信息
     */
    @Override
    public List<UserAddress> selectUserAddressList(UserAddress userAddress)
    {
        return userAddressMapper.selectUserAddressList(userAddress);
    }

    /**
     * 新增用户收货地址信息
     *
     * @param userAddress 用户收货地址信息
     * @return 结果
     */
    @Override
    public int insertUserAddress(UserAddress userAddress)
    {
        userAddress.setCreateTime(DateUtils.getNowDate());
        return userAddressMapper.insertUserAddress(userAddress);
    }

    /**
     * 修改用户收货地址信息
     *
     * @param userAddress 用户收货地址信息
     * @return 结果
     */
    @Override
    public int updateUserAddress(UserAddress userAddress)
    {
        userAddress.setUpdateTime(DateUtils.getNowDate());
        return userAddressMapper.updateUserAddress(userAddress);
    }

    /**
     * 批量删除用户收货地址信息
     *
     * @param addressIds 需要删除的用户收货地址信息ID
     * @return 结果
     */
    @Override
    public int deleteUserAddressByIds(Long[] addressIds)
    {
        return userAddressMapper.deleteUserAddressByIds(addressIds);
    }

    /**
     * 删除用户收货地址信息信息
     *
     * @param addressId 用户收货地址信息ID
     * @return 结果
     */
    @Override
    public int deleteUserAddressById(Long addressId)
    {
        return userAddressMapper.deleteUserAddressById(addressId);
    }

    @Override
    public UserAddress selectUserAddressByShopId(Long addressId, Long shopId) {
        return userAddressMapper.selectUserAddressByShopId(addressId,shopId);
    }

    @Override
    public int updateUserAddressStatus(Long userId, String status) {
        return userAddressMapper.updateUserAddressStatus(userId,status);
    }

}
